using UnityEngine;
using System.Collections;

public class TurnOff : MonoBehaviour {

	public GameObject intro;
	public Renderer panela;
	public GameObject Win;
	public GameObject Loser;
	public GameObject NotFerver;
	public GameObject AguaFervendo;
	float cronometro;
	Color corPanela;
	float i;
	bool podeIniciar;
	bool returnScene;
	void Awake()
	{
		corPanela.a = 1;
	}
	
	void Start () 
	{
		Destroy(intro,5);
	}
	
	// Update is called once per frame
	void Update () 
	{
		cronometro+= Time.deltaTime;
		if(!podeIniciar && cronometro >5 )
		{
			cronometro = 0;
			podeIniciar = true;
		}
		if(podeIniciar)
		{
			i += 0.0013f;
			corPanela.r += i;
			panela.material.color = corPanela;
		
			if(Input.GetKeyDown(KeyCode.Return) && cronometro < 6)
			{
				NotFerver.SetActive(true);
				float cronoAlternativo = cronometro;
			}
			if(cronometro > cronometro + 1.3f)
			{
				NotFerver.SetActive(false);
			}
		
			if(cronometro > 7 && cronometro < 10 && Input.GetKeyDown(KeyCode.Return))
			{
				Win.SetActive(true);
				AguaFervendo.SetActive(false);
				NotFerver.SetActive(false);
				PlayerPrefs.SetInt("Count",5);
				this.enabled = false;
			}

			if(cronometro > 10)
			{
				NotFerver.SetActive(false);
				Loser.SetActive(true);
				AguaFervendo.SetActive(false);
				this.enabled = false;
			}
		}
	}
}
